$(function() {
	$("#btn-signin").click(function() {
		var username = $.trim($("#username").val());
		var password = $.trim($("#password").val());

		if (username == "") {
			$('#error').css('display', 'block');
			$('#error').html('请输入您的用户名');
			$("#username").focus();
			return;
		}
		if (password == "") {
			$('#error').css('display', 'block');
			$('#error').html('请输入密码');
			$("#password").focus();
			return;
		}

		var json_message = {
			username: username,
			password: password,
		};

		var url = '/signin';

		$.ajax({
			type: "POST",
			url: url,
			data: JSON.stringify(json_message),
			success: function(data) {
				console.log(data);
				if (data.result === '0') {
					alert(data.message);
				} else {
					alert('登陆成功');
				}
			},
			dataType: "json",
			contentType: "application/json",
			processData: false,
		});
	});

});